home *** CD-ROM | disk | FTP | other *** search
- Path: news.sfu.ca!mpohores
- From: mpohores@news.sfu.ca (Michael John Pohoreski)
- Newsgroups: comp.lang.c++
- Subject: int (*p)[4]; (Watcom problem)
- Date: 9 Apr 1996 01:02:59 GMT
- Organization: Simon Fraser University
- Message-ID: <4kcd03$37j@morgoth.sfu.ca>
- NNTP-Posting-Host: fraser.sfu.ca
- Summary: How do I use this defn. of pointer to array?
- Keywords: WATCOM C++ POINTER ARRAY PROBLEM
- X-Newsreader: NN version 6.5.0 #5 (NOV)
-
- I came across (ARM, page 97) the following way to define
- a pointer to an array:
- int (*p)[];
-
- (Yes, I allready know I can just do: int *p)
- So I tried it in a small C++ test program: p2a.cpp
-
- #include <stdio.h>
-
- void main( void )
- {
- int a[4] = { -13, 11, -7, 5 };
- int (*x)[4]; // pointer to array
-
- for (int i = 0; i < 4; i++ )
- {
- (int *)x = &a[i];
- printf( "%d\n", (*x)[0] );
- }
- }
-
- Now here's my problem:
- Under Watcom 10.5, the above doesn't compile with wcl386
- but it compiles under DJGPP 2.0, and Borland C++ 3.1 Anyone know why?
-
- Is this a bug?
-
- Please email.
-
- (ARM is The C++ Annotated Reference Manual)
- --
- mpohores@sfu.ca
- Only in Canada, are traitors called separatists.
-